package com.minmin;

import com.minmin.common.Driver;
import com.minmin.common.DriverConfig;
import com.minmin.testCases.TestProduct;
import com.minmin.testCases.TestPurchase;
import com.minmin.testCases.TestStaff;
import com.minmin.testCases.TestStock;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.WebDriver;

public class Web {
    public static void main(String[] args) {
        new Thread(new Run(new DriverConfig("ly1",
                "123456",
                "https://fbbc.wsmsd.cn/b2c-merchant-admin/#/login",
                "//button/span[text()=\"商品同步测试\"]"))).start();
//
//        new Thread(new Run(new DriverConfig("zdhcs",
//                "123456",
//                "https://yc.lakala.com/b2c-merchant-admin/#/login",
//                "https://yxd.lakala.com/b2c-merchant-admin/#/login",
//                "//button/span[text()=\"生产自动化回归店铺(零售版)\"]"))).start();
    }
}

@Slf4j
class Run implements Runnable {
    private final DriverConfig config;

    public Run(DriverConfig config) {
        this.config = config;
    }

    @Override
    public void run() {
        WebDriver driver = null;
        try {
            driver = new Driver(this.config).getDriver();

            log.info("测试相关商品功能");
            new TestProduct(driver).testProduct();
            Thread.sleep(1000);

            log.info("测试采购相关功能");
            new TestPurchase(driver).testPurchase();
            Thread.sleep(1000);

            log.info("测试仓储模块");
            new TestStock(driver).testStock();
            Thread.sleep(1000);

            log.info("测试人员模块");
            new TestStaff(driver).testStaff();
            Thread.sleep(1000);

        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } finally {
            driver.close();
        }
    }
}
